package history.study.tow_pointer;

public class LeetCode_206 {
    public ListNode reverseList(ListNode head) {
        if (head == null || head.next==null) return head;
        ListNode fastListNode = head.next;
        ListNode slowListNode = head;
        ListNode lastSlowListNode = null;
        while (fastListNode!=null) {
            ListNode nextFastListNode = fastListNode.next;
            fastListNode.next = slowListNode;
            slowListNode.next = lastSlowListNode;
            lastSlowListNode = slowListNode;
            slowListNode = fastListNode;
            fastListNode = nextFastListNode;
        }
        return slowListNode;
    }
}
